home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 1.iso
/
ARGONET
/
PD
/
WWW
/
TABLE.ZIP
/
!Table2HTM
/
ShellData
< prev
next >
Wrap
Text File
|
1997-03-17
|
7KB
|
357 lines
Table2HTML
!Table2htm
Table2HTML
0
1
6
Convert files to HTML
© Victor Markwart
0.03 (16-Feb-1997)
0
***
***
***
***
***
***
iconmenu%
Table2HTML
...Info !
...Options...&menu_klik(1)
...Quit&CLOSEDOWN
¤
@
menu_klik
button%
4
IF button%<>2 THEN OPENDIALOGUE(options, 368, 354)
ENDPROC
¤
drag_file
file$,type%
5
infile$=file$
CASE type% OF
WHEN &DFE : opt_type%=1 : OPENDIALOGUE(saveas%, 148, 254) : REM CSV
WHEN &FFF : OPENDIALOGUE(saveas%, 148, 254) : REM TEXT
OTHERWISE
OPENDIALOGUE(query1, 369, 336)
ENDCASE
ENDPROC
¤
start_up
***
1
'Icon Definitions
'Options window: icon numbers
opt_save=0: opt_set=1: opt_cancel=2
opt_csv=5: opt_txt=6: opt_tsv=7
opt_bord=10: opt_head=11: opt_colhead=12: opt_rowhead=13
opt_cols=16: opt_rows=17: opt_off=18
opt_capt_txt=19: opt_capt=20
'Huh
q1_cont=0: q1_cancel=1
'Saveas
sav_ok=2: sav_name=1
'Global variables
tab%=9
lf%=10
cr%=13
space%=32
quote%=34
quote$=CHR$(quote%)
comma%=44
DIM td%(4)
DIM td$(4)
ON ERROR LOCAL: CLOSE#in% : PROCdefault : ENDPROC
in%=OPENIN(taskdir$+".Options")
INPUT#in%, name$
IF name$<>"Table2HTML" THEN
opt_type%=1
opt_bord%=1
opt_head%=0
opt_colhead%=0
opt_rowhead%=0
opt_span%=3
opt_capt%=0
opt_capt$=""
ELSE
INPUT#in%, opt_type%
INPUT#in%, opt_bord%
INPUT#in%, opt_head%
INPUT#in%, opt_colhead%
INPUT#in%, opt_rowhead%
INPUT#in%, opt_span%
INPUT#in%, opt_capt%
INPUT#in%, opt_capt$
ENDIF
CLOSE#in%
opt_tail%=opt_head%
SETSTATE(options, 4+opt_type%,1)
SETSTATE(options, opt_bord, opt_bord%)
SETSTATE(options, opt_head, opt_head%)
SETSTATE(options, opt_colhead, opt_colhead%)
SETSTATE(options, opt_rowhead, opt_rowhead%)
SETSTATE(options, 15+opt_span%, 1)
SETSTATE(options, opt_capt, opt_capt%)
SETICON(options, opt_capt_txt, opt_capt$)
ENDPROC
¤
win_klik
window%,icon%,button%
10
IF window%=options THEN
CASE icon% OF
WHEN opt_cancel: CLOSEWINDOW(options)
WHEN opt_set:
opt_type%=GROUPSTATE(options, 1)-4
PROCtype
opt_bord%=READSTATE(options, opt_bord)
opt_head%=READSTATE(options, opt_head)
opt_colhead%=READSTATE(options, opt_colhead)
opt_rowhead%=READSTATE(options, opt_rowhead)
opt_span%=GROUPSTATE(options, 2)-15
opt_capt%=READSTATE(options, opt_capt)
opt_capt$=READICON(options, opt_capt_txt)
CLOSEWINDOW(options)
WHEN opt_save:
opt_type%=GROUPSTATE(options, 1)-4
PROCtype
opt_bord%=READSTATE(options, opt_bord)
opt_head%=READSTATE(options, opt_head)
opt_colhead%=READSTATE(options, opt_colhead)
opt_rowhead%=READSTATE(options, opt_rowhead)
opt_span%=GROUPSTATE(options, 2)-15
opt_capt%=READSTATE(options, opt_capt)
opt_capt$=READICON(options, opt_capt_txt)
out%=OPENOUT(taskdir$ + ".Options")
PRINT#out%, "Table2HTML"
PRINT#out%, opt_type%
PRINT#out%, opt_bord%
PRINT#out%, opt_head%
PRINT#out%, opt_colhead%
PRINT#out%, opt_rowhead%
PRINT#out%, opt_span%
PRINT#out%, opt_capt%
PRINT#out%, opt_capt$
CLOSE#out%
CLOSEWINDOW(options)
ENDCASE
opt_tail%=opt_head%
ENDIF
IF window%=query1 THEN
CASE icon% OF
WHEN q1_cancel : CLOSEWINDOW(query1)
WHEN q1_cont : CLOSEWINDOW(query1) : OPENDIALOGUE(saveas%, 148, 254)
ENDCASE
ENDIF
ENDPROC
¤
convert_file
file$
9
td$(1)="<td>"
td$(2)="</td>"
td$(3)="<th>"
td$(4)="</th>"
crlf$=CHR$(13) + CHR$(10)
newtable%=TRUE : REM Start new table
newrow%=TRUE : REM Start new row
newcell%=TRUE : REM Start new cell
endcell%=FALSE : REM We haven't started yet
endrow%=FALSE
endtable%=FALSE
colcount%=0
rowcount%=0
action%=0 : REM 4 endtable% : 2 endrow% : 1 endcell%
space=0
lastaction%=7 : REM 4 endtable% ¦ 2 endrow% ¦ 1 endcell%
td%(1)=1 : td%(2)=2 : td%(3)=1 : td%(4)=2
flg_ctrl=0 : REM Flag for unwanted control characters
HOURON
in%=OPENIN(infile$)
out%=OPENOUT(file$)
IF (opt_head% <> 0) THEN PROCoutput_head
BPUT#out%, "<!--Created by Table2HTML © Victor Markwart 1997 --!>"
BPUT#out%, "<!--Written using WimpWorks by Jaffa Software --!>"
BPUT#out%, "<table";
IF (opt_bord%<>FALSE) THEN BPUT#out%, " border";
BPUT#out%, ">"
IF (opt_capt%<>FALSE) THEN
BPUT#out%, "<caption=";
BPUT#out%, quote$;
BPUT#out%, opt_capt$;
BPUT#out%, quote$;
BPUT#out%, ">"
ENDIF
WHILE NOT EOF#(in%)
inchar%=BGET#in%
IF (lastaction%>0) THEN
IF ((lastaction% AND 2)=2) THEN
BPUT#out%, "<tr>";
rowcount%+=1
colcount%=0
IF (opt_rowhead% <>0) THEN
td%(1)=3 : td%(2)=4 : td%(3)=1 : td%(4)=2
ELSE
td%(1)=1 : td%(2)=2 : td%(3)=1 : td%(4)=2
ENDIF
IF (rowcount%<2) THEN
IF (opt_colhead%<>0) THEN
td%(1)=3 : td%(2)=4 : td%(3)=3 : td%(4)=4
ENDIF
ENDIF
ENDIF
IF ((lastaction% AND 1)=1) THEN
colcount%+=1
IF (colcount% < 2) THEN
BPUT#out%, td$(td%(1));
ELSE
BPUT#out%, td$(td%(3));
ENDIF
ENDIF
ENDIF
CASE inchar% OF
WHEN tab% :
IF opt_tsv THEN action%=action% OR 1
WHEN comma% :
IF opt_csv THEN action%=action% OR 1
WHEN space% :
IF opt_txt THEN
space+=1
IF space>1 THEN inchar%=0
IF space=2 THEN action%=action% OR 1
ENDIF
WHEN lf%, cr%:
action%=action% OR 3
OTHERWISE
space=0
ENDCASE
IF (action%>0) THEN
inchar%=0
IF ((action% AND 1)=1) THEN
IF (colcount%<2) THEN
BPUT#out%, td$(td%(2))
ELSE
BPUT#out%, td$(td%(4))
ENDIF
ENDIF
IF ((action% AND 2)=2) THEN BPUT#out%, "</tr>"
ELSE
IF (space>1) THEN action%=action% OR 1: space=0
IF (inchar%<>quote%) THEN BPUT#out%, inchar%
ENDIF
lastaction%=action%
action%=0
ENDWHILE
BPUT#out%, "</table>"
IF (opt_tail% <> 0) THEN PROCoutput_tail
CLOSE#in%
CLOSE#out%
SYS "XOS_CLI","Settype "+file$+" FAF"
HOUROFF
ENDPROC
¤
output_head
***
0
BPUT#out%, "<html>"
BPUT#out%, "<head>"
BPUT#out%, "<title>";
temp$ = LEAFNAME(infile$)
BPUT#out%, temp$;
BPUT#out%, "</title>"
BPUT#out%, "</head>"
BPUT#out%, "<body>"
BPUT#out%, "<a name=";
BPUT#out%, CHR$(34);
BPUT#out%, "top";
BPUT#out%, CHR$(34);
BPUT#out%, ">"
BPUT#out%, "<hr>"
ENDPROC
¤
output_tail
***
0
BPUT#out%, "<hr>"
BPUT#out%, "<a href=";
BPUT#out%, CHR$(34);
BPUT#out%, "#top";
BPUT#out%, CHR$(34);
BPUT#out%, ">Back to top</a><br>"
BPUT#out%, "</body>"
BPUT#out%, "</html>"
ENDPROC
¤
type
***
0
opt_csv%=FALSE
opt_txt%=FALSE
opt_tsv%=FALSE
CASE opt_type% OF
WHEN 1 : opt_csv%=TRUE
WHEN 2 : opt_txt%=TRUE
WHEN 3 : opt_tsv%=TRUE
OTHERWISE
WARNING("Not sure which filetype to use", "Table2HTML")
ENDCASE
ENDPROC
¤
default
***
0
opt_type%=1
opt_bord%=1
opt_head%=0
opt_colhead%=0
opt_rowhead%=0
opt_span%=3
opt_capt%=0
opt_capt$=""
'This next bit could be a separate procedure shared with startup
opt_tail%=opt_head%
SETSTATE(options, 4+opt_type%,1)
SETSTATE(options, opt_bord, opt_bord%)
SETSTATE(options, opt_head, opt_head%)
SETSTATE(options, opt_colhead, opt_colhead%)
SETSTATE(options, opt_rowhead, opt_rowhead%)
SETSTATE(options, 15+opt_span%, 1)
SETSTATE(options, opt_capt, opt_capt%)
SETICON(options, opt_capt_txt, opt_capt$)
ENDPROC
¤
@